package com.hu.zhcc.shiro.service.Responsitory;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.shiro.dao.RIllnessMapper;
import com.hu.zhcc.shiro.entity.Reponsitory.RIllness;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class RillnessServiceImpl implements RillnessService {

    @Autowired
    private RIllnessMapper illnessMapper;

    @Override
    public Page<RIllness> selectAll(Map<String, String> map, RIllness rIllness) {
        Integer offset = Integer.valueOf(map.get("offset"));
        Integer limit = Integer.valueOf(map.get("limit"));
        PageHelper.startPage(offset, limit);
        List<RIllness> rIllnesses = illnessMapper.selectIllAll(rIllness);
        PageInfo<RIllness> pageInfo = new PageInfo<>(rIllnesses);
        return new Page<RIllness>(pageInfo.getTotal(), rIllnesses);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return illnessMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(RIllness record) {
        return illnessMapper.insertSelective(record);
    }

    @Override
    public RIllness beforeUpdateById(int id) {
        return illnessMapper.beforeUpdateById(id);
    }

    @Override
    public int updateByPrimaryKeySelective(RIllness record) {
        return illnessMapper.updateByPrimaryKeySelective(record);
    }
}
